package com.java2;
/*
 * 接口的应用：代理模式
 *
 */
public class NetWorkTest {

    public static void main(String[] args) {
        Proxy proxy = new Proxy(new Server());
        proxy.browse();
    }
}


interface NetWork{

    void browse();
}

class Server implements NetWork{

    @Override
    public void browse() {
        System.out.println("真正的服务器访问网络");
    }
}

class Proxy implements NetWork{

    private Server server;

    public Proxy(Server server) {
        this.server = server;
    }

    public void  check(){
        System.out.println("联网之前的检查工作");
    }
    @Override
    public void browse() {
        check();
        server.browse();
    }
}